<?php
/**
 * Handle控制器
 */
namespace app\manage\controller\option;

use app\manage\controller\Base;
use app\common\cache\CacheData;

class Handle extends Base
{

    private $params;
    public function __construct(){
        parent::__construct();
        // token验证
        if(false == Base::checkToken()){
            $this->error('token error!');
        }
        // 参数去token
        $params = input('post.');
        unset($params['token']);
        $this->params = $params;
    }

    public function save(){
        $params = $this->params;
        
        foreach($params as $key => $value):
            model('option') -> addOneData($key,$value);
        endforeach;
        // 更新缓存
        $CACHE = CacheData::getInstance('Option');
        $CACHE -> updateCache();
        $this -> success('保存成功！');
    }

}
